In the mathematical subfield of numerical analysis a cubic Hermite spline (also called cspline), named in honor of Charles Hermite, is a third-degree spline with each polynomial of the spline in Hermite form. The Hermite form consists of two control points and two control tangents for each polynomial.
For interpolation on a grid with points for , interpolation is performed on one subinterval at a time (given that tangent values are predetermined). The subinterval is normalized to via .
Contents |
On the unit interval , given a starting point p0 at and an ending point p1 at with starting tangent m0 at and ending tangent m1 at , the polynomial can be defined by
where t ∈ [0, 1].
Interpolating in the interval can now be done with the formula
with and refers to the basis functions, defined below. Note that the tangent values have been scaled by compared to the equation on the unit interval.
The formulae specified above are guaranteed to produce a unique path between the two points.
Proof:
Let be another third degree polynomial satisfying the given boundary conditions. Define . Since both and are third degree polynomials, is at most a third degree polynomial. Furthermore:
So must be of the form:
We know furthermore that:
Putting and together, we deduce that and , thus
We can write the interpolation polynomial as
where are Hermite basis functions. These can be written in different ways, each way revealing different properties.
expanded | factorized | Bernstein | |
---|---|---|---|
The "expanded" column shows the representation used in the definition above. The "factorized" column shows immediately, that and are zero at the boundaries. You can further conclude that and have a zero of multiplicity 2 at 0 and and have such a zero at 1, thus they have slope 0 at those boundaries. The "Bernstein" column shows the decomposition of the Hermite basis functions into Bernstein polynomials of order 3:
Using this connection you can express cubic Hermite interpolation in terms of cubic Bézier curves with respect to the four values and do Hermite interpolation using the de Casteljau algorithm. It shows that in a cubic Bézier patch the two control points in the middle determine the tangents of the interpolation curve at the respective outer points.
A data set, for , can be interpolated by applying the above procedure on each interval, where the tangents are chosen in a sensible manner, meaning that the tangents for intervals sharing endpoints are equal. The interpolated curve then consists of piecewise cubic Hermite splines, and is globally continuously differentiable in .
The choice of tangents is non-unique, and there are several options available.
The simplest choice is the three-point difference, not requiring constant interval lengths,
for internal points , and one-sided difference at the endpoints of the data set.
A cardinal spline is obtained[1] if
is used to calculate the tangents. The parameter is a tension parameter that must be in the interval . In some sense, this can be interpreted as the "length" of the tangent. will yield all zero tangents, and yields a Catmull–Rom spline.
For tangents chosen to be
a Catmull–Rom spline is obtained, being a special case of a cardinal spline.
The curve is named after Edwin Catmull and Raphael (Raphie) Rom. In computer graphics, Catmull–Rom splines are frequently used to get smooth interpolated motion between key frames. For example, most camera path animations generated from discrete key-frames are handled using Catmull–Rom splines. They are popular mainly for being relatively easy to compute, guaranteeing that each key frame position will be hit exactly, and also guaranteeing that the tangents of the generated curve are continuous over multiple segments.
A Kochanek–Bartels spline is a further generalization on how to choose the tangents given the data points , and , with three parameters possible, tension, bias and a continuity parameter.
If a cubic Hermite spline of any of the above listed types is used for interpolation of a monotonic data set, the interpolated function will not necessarily be monotonic, but monotonicity can be preserved by adjusting the tangents.
Given p-1, p0, p1 and p2 as the values that the function should take on at -1, 0, 1 and 2, we can use centered differences instead of exact derivatives.[2] Thus the Catmull–Rom spline is
for , where the left-hand vector is independent of the p.
This writing is relevant for tricubic interpolation, where one optimization requires you to compute CINTx sixteen times with the same x and different p.